package korlibs.render

import korlibs.datastructure.IntMap
import korlibs.event.Key
import platform.UIKit.*

@Suppress("OPT_IN_USAGE", "RemoveRedundantCallsOfConversionMethods")
object IosKeyMap {
    val KEY_MAP = IntMap<Key>()
    fun put(keyCode: UIKeyboardHIDUsage, key: Key) {
        KEY_MAP[keyCode.toInt()] = key
    }
    init {
        // Alphabetical Keys
        put(UIKeyboardHIDUsageKeyboardA, Key.A)
        put(UIKeyboardHIDUsageKeyboardB, Key.B)
        put(UIKeyboardHIDUsageKeyboardC, Key.C)
        put(UIKeyboardHIDUsageKeyboardD, Key.D)
        put(UIKeyboardHIDUsageKeyboardE, Key.E)
        put(UIKeyboardHIDUsageKeyboardF, Key.F)
        put(UIKeyboardHIDUsageKeyboardG, Key.G)
        put(UIKeyboardHIDUsageKeyboardH, Key.H)
        put(UIKeyboardHIDUsageKeyboardI, Key.I)
        put(UIKeyboardHIDUsageKeyboardJ, Key.J)
        put(UIKeyboardHIDUsageKeyboardK, Key.K)
        put(UIKeyboardHIDUsageKeyboardL, Key.L)
        put(UIKeyboardHIDUsageKeyboardM, Key.M)
        put(UIKeyboardHIDUsageKeyboardN, Key.N)
        put(UIKeyboardHIDUsageKeyboardO, Key.O)
        put(UIKeyboardHIDUsageKeyboardP, Key.P)
        put(UIKeyboardHIDUsageKeyboardQ, Key.Q)
        put(UIKeyboardHIDUsageKeyboardR, Key.R)
        put(UIKeyboardHIDUsageKeyboardS, Key.S)
        put(UIKeyboardHIDUsageKeyboardT, Key.T)
        put(UIKeyboardHIDUsageKeyboardU, Key.U)
        put(UIKeyboardHIDUsageKeyboardV, Key.V)
        put(UIKeyboardHIDUsageKeyboardW, Key.W)
        put(UIKeyboardHIDUsageKeyboardX, Key.X)
        put(UIKeyboardHIDUsageKeyboardY, Key.Y)
        put(UIKeyboardHIDUsageKeyboardZ, Key.Z)
        // Numerical Keys)
        put(UIKeyboardHIDUsageKeyboard0, Key.N0)
        put(UIKeyboardHIDUsageKeyboard1, Key.N1)
        put(UIKeyboardHIDUsageKeyboard2, Key.N2)
        put(UIKeyboardHIDUsageKeyboard3, Key.N3)
        put(UIKeyboardHIDUsageKeyboard4, Key.N4)
        put(UIKeyboardHIDUsageKeyboard5, Key.N5)
        put(UIKeyboardHIDUsageKeyboard6, Key.N6)
        put(UIKeyboardHIDUsageKeyboard7, Key.N7)
        put(UIKeyboardHIDUsageKeyboard8, Key.N8)
        put(UIKeyboardHIDUsageKeyboard9, Key.N9)

        // Symbol Keys
        put(UIKeyboardHIDUsageKeyboardBackslash, Key.BACKSLASH)
        put(UIKeyboardHIDUsageKeyboardCloseBracket, Key.CLOSE_BRACKET)
        put(UIKeyboardHIDUsageKeyboardComma, Key.COMMA)
        put(UIKeyboardHIDUsageKeyboardEqualSign, Key.EQUAL)
        put(UIKeyboardHIDUsageKeyboardHyphen, Key.HYPHEN)
        put(UIKeyboardHIDUsageKeyboardNonUSBackslash, Key.BACKSLASH)
        put(UIKeyboardHIDUsageKeyboardNonUSPound, Key.POUND)
        put(UIKeyboardHIDUsageKeyboardOpenBracket, Key.OPEN_BRACKET)
        put(UIKeyboardHIDUsageKeyboardPeriod, Key.PERIOD)
        put(UIKeyboardHIDUsageKeyboardQuote, Key.QUOTE)
        put(UIKeyboardHIDUsageKeyboardSemicolon, Key.SEMICOLON)
        put(UIKeyboardHIDUsageKeyboardSeparator, Key.KP_SEPARATOR)
        put(UIKeyboardHIDUsageKeyboardSlash, Key.SLASH)
        put(UIKeyboardHIDUsageKeyboardSpacebar, Key.SPACE)

        // Modifier Keys)
        put(UIKeyboardHIDUsageKeyboardCapsLock, Key.CAPS_LOCK)
        put(UIKeyboardHIDUsageKeyboardLeftAlt, Key.LEFT_ALT)
        put(UIKeyboardHIDUsageKeyboardLeftControl, Key.LEFT_CONTROL)
        put(UIKeyboardHIDUsageKeyboardLeftShift, Key.LEFT_SHIFT)
        put(UIKeyboardHIDUsageKeyboardLockingCapsLock, Key.CAPS_LOCK)
        put(UIKeyboardHIDUsageKeyboardLockingNumLock, Key.NUM_LOCK)
        put(UIKeyboardHIDUsageKeyboardLockingScrollLock, Key.SCROLL_LOCK)
        put(UIKeyboardHIDUsageKeyboardRightAlt, Key.RIGHT_ALT)
        put(UIKeyboardHIDUsageKeyboardRightControl, Key.RIGHT_CONTROL)
        put(UIKeyboardHIDUsageKeyboardRightShift, Key.RIGHT_SHIFT)
        put(UIKeyboardHIDUsageKeyboardScrollLock, Key.SCROLL_LOCK)

        // Navigation Keys
        put(UIKeyboardHIDUsageKeyboardLeftArrow, Key.LEFT)
        put(UIKeyboardHIDUsageKeyboardRightArrow, Key.RIGHT)
        put(UIKeyboardHIDUsageKeyboardUpArrow, Key.UP)
        put(UIKeyboardHIDUsageKeyboardDownArrow, Key.DOWN)
        put(UIKeyboardHIDUsageKeyboardPageUp, Key.PAGE_UP)
        put(UIKeyboardHIDUsageKeyboardPageDown, Key.PAGE_DOWN)
        put(UIKeyboardHIDUsageKeyboardHome, Key.HOME)
        put(UIKeyboardHIDUsageKeyboardEnd, Key.END)
        put(UIKeyboardHIDUsageKeyboardDeleteOrBackspace, Key.BACKSPACE)
        put(UIKeyboardHIDUsageKeyboardDeleteForward, Key.DELETE)
        put(UIKeyboardHIDUsageKeyboardEscape, Key.ESCAPE)
        put(UIKeyboardHIDUsageKeyboardInsert, Key.INSERT)
        put(UIKeyboardHIDUsageKeyboardReturn, Key.RETURN)
        put(UIKeyboardHIDUsageKeyboardReturnOrEnter, Key.RETURN)
        put(UIKeyboardHIDUsageKeyboardTab, Key.TAB)

        // Function Keys
        put(UIKeyboardHIDUsageKeyboardF1, Key.F1)
        put(UIKeyboardHIDUsageKeyboardF2, Key.F2)
        put(UIKeyboardHIDUsageKeyboardF3, Key.F3)
        put(UIKeyboardHIDUsageKeyboardF4, Key.F4)
        put(UIKeyboardHIDUsageKeyboardF5, Key.F5)
        put(UIKeyboardHIDUsageKeyboardF6, Key.F6)
        put(UIKeyboardHIDUsageKeyboardF7, Key.F7)
        put(UIKeyboardHIDUsageKeyboardF8, Key.F8)
        put(UIKeyboardHIDUsageKeyboardF9, Key.F9)
        put(UIKeyboardHIDUsageKeyboardF10, Key.F10)
        put(UIKeyboardHIDUsageKeyboardF11, Key.F11)
        put(UIKeyboardHIDUsageKeyboardF12, Key.F12)
        put(UIKeyboardHIDUsageKeyboardF13, Key.F13)
        put(UIKeyboardHIDUsageKeyboardF14, Key.F14)
        put(UIKeyboardHIDUsageKeyboardF15, Key.F15)
        put(UIKeyboardHIDUsageKeyboardF16, Key.F16)
        put(UIKeyboardHIDUsageKeyboardF17, Key.F17)
        put(UIKeyboardHIDUsageKeyboardF18, Key.F18)
        put(UIKeyboardHIDUsageKeyboardF19, Key.F19)
        put(UIKeyboardHIDUsageKeyboardF20, Key.F20)
        put(UIKeyboardHIDUsageKeyboardF21, Key.F21)
        put(UIKeyboardHIDUsageKeyboardF22, Key.F22)
        put(UIKeyboardHIDUsageKeyboardF23, Key.F23)
        put(UIKeyboardHIDUsageKeyboardF24, Key.F24)

        // Keypad Keys
        put(UIKeyboardHIDUsageKeypad0, Key.KP_0)
        put(UIKeyboardHIDUsageKeypad1, Key.KP_1)
        put(UIKeyboardHIDUsageKeypad2, Key.KP_2)
        put(UIKeyboardHIDUsageKeypad3, Key.KP_3)
        put(UIKeyboardHIDUsageKeypad4, Key.KP_4)
        put(UIKeyboardHIDUsageKeypad5, Key.KP_5)
        put(UIKeyboardHIDUsageKeypad6, Key.KP_6)
        put(UIKeyboardHIDUsageKeypad7, Key.KP_7)
        put(UIKeyboardHIDUsageKeypad8, Key.KP_8)
        put(UIKeyboardHIDUsageKeypad9, Key.KP_9)
        put(UIKeyboardHIDUsageKeypadAsterisk, Key.KP_MULTIPLY)
        put(UIKeyboardHIDUsageKeypadComma, Key.KP_COMMA)
        put(UIKeyboardHIDUsageKeypadEnter, Key.KP_ENTER)
        put(UIKeyboardHIDUsageKeypadEqualSign, Key.KP_EQUAL)
        put(UIKeyboardHIDUsageKeypadEqualSignAS400, Key.KP_EQUAL)
        put(UIKeyboardHIDUsageKeypadHyphen, Key.KP_SUBTRACT)
        put(UIKeyboardHIDUsageKeypadNumLock, Key.NUM_LOCK)
        put(UIKeyboardHIDUsageKeypadPeriod, Key.KP_DOT)
        put(UIKeyboardHIDUsageKeypadPlus, Key.KP_ADD)
        put(UIKeyboardHIDUsageKeypadSlash, Key.KP_DIVIDE)

        // Media Keys
        put(UIKeyboardHIDUsageKeyboardPause, Key.PAUSE)
        put(UIKeyboardHIDUsageKeyboardStop, Key.MEDIA_STOP)
        put(UIKeyboardHIDUsageKeyboardMute, Key.MUTE)
        put(UIKeyboardHIDUsageKeyboardVolumeUp, Key.VOLUME_UP)
        put(UIKeyboardHIDUsageKeyboardVolumeDown, Key.VOLUME_DOWN)

        // ...
    }
}
